<?php
/**
 * ControllerAdmin.class.php
 * - Use controler of project
 * @author PHUNG VAN TAM
 * @since version - Aug 4, 2011
 * $Id: $
 */
require_once(LIB_DAO_DIR . "/DanhMuc.class.php");
require_once(LIB_DAO_DIR . "/SanphamCategory.class.php");
require_once(LIB_DAO_DIR . "/SanphamSCategory.class.php");
require_once(LIB_DAO_DIR . "/MSanpham.class.php");
require_once(LIB_DAO_DIR . "/KhoHang.class.php");
class ControllerAdmin {
	// Default properties
    public $tpl_title;
    public $loginFlag = false;
    public $tpl_title_list;
    /**
     * init
     * - Constructor
     */
    public function __construct() {
    	$this->dataUser = Session::Get("MUSER");
        if (is_array($this->dataUser) && !empty($this->dataUser)) {
        	$this->loginFlag = true;
        }
        
        $this->getListDanhMuc = $this->getListDanhMuc();
    }
    
    public function isPost() {
    	if (isset($_POST['mode']) || isset($_POST['itemID']) || isset($_POST['type'])) {
    		return true;
    	}
    	return false;
    }
    
    public function getListDanhMuc() {
    	$ojbDanhMuc = new DanhMuc();
    	$ojbCate = new SanphamCategory();
    	$ojbCateSub = new SanphamSCategory();
    	$arrayVa = array();
    	
    	$danhMucA = $ojbDanhMuc->getAllByAttribute(array());
		if (count($danhMucA) > 0) {
			$i=0;
			foreach ($danhMucA as $danhmuc) {
				$danhmuc['value'] = '';
				$arrayVa[$i] = $danhmuc;
		    	$dataCateA = $ojbCate->getListAll($danhmuc['id']);
		    	if (count($dataCateA) > 0) {
		    		$j=0;
		    		foreach ($dataCateA as $dataC) {
		    			$dataC['value'] = '';
		    			$arrayVa[$i]['value'][$j] = $dataC;
		    			$dataSCate = $ojbCateSub->getListAll($danhmuc['id'], $dataC['id'], true);
		    			if (count ($dataSCate) > 0) {
		    				foreach ($dataSCate as $dataSub) {
		    					$arrayVa[$i]['value'][$j]['value'][] = $dataSub;
		    				}
		    			}
		    			$j++;
		    		}
		    	}
		    	$i++;
			}
		}//echo"<pre>";print_r($arrayVa);exit;
    	return $arrayVa;
    }
}
?>